package com.louis.web.tag;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

public abstract class AbstractTag extends TagSupport {

	private static final long	serialVersionUID	= -548528021253453608L;

	private HttpServletRequest	request;
	private HttpServletResponse	response;
	private HttpSession			session;

	@Override
	public final int doStartTag() throws JspException {
		request = (HttpServletRequest) this.pageContext.getRequest();
		response = (HttpServletResponse) this.pageContext.getResponse();
		session = this.pageContext.getSession();
		try {
			return doStartTagInternal();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return -1;
	}

	public abstract int doStartTagInternal() throws Exception;

	public HttpServletRequest getRequest() {
		return request;
	}

	public HttpServletResponse getResponse() {
		return response;
	}

	public HttpSession getSession() {
		return session;
	}

}
